import { axios } from '@/utils/request'
import { ExcelDownLoad, WordDownLoad } from '@/myService/FileDownLoad'

let baseUrl="/data-governance/epidemicDaily";
export default {
    getCategoryInfo: function (isDelete) {
        return axios({
            url: baseUrl+"/getCategoryInfo",
            method: "GET",
            params: {isDelete: isDelete}
        })
    },
    changeCategoryStatus: function (id) {
        return axios({
            url: baseUrl+"/changeCategoryStatus",
            method: "GET",
            params: {id: id}
        })
    },
  deleteCategory: function (id) {
    return axios({
      url: baseUrl+"/deleteCategory",
      method: "GET",
      params: {id: id}
    })
  },
    addCategoryKey: function (params) {
        return axios({
            url: baseUrl+"/addCategoryKey",
            method: "GET",
            params: params
        })
    },
    delCategoryKeyStatus: function (param) {
        return axios({
            url: baseUrl+"/delCategoryKeyStatus",
            method: "GET",
            params: param
        })
    },
    addCategory: function (data) {
        return axios({
            url: baseUrl+"/addCategory",
            method: "POST",
            data: data
        })
    },
    changeCategoryInfo: function (data) {
        return axios({
            url: baseUrl+"/changeCategoryInfo",
            method: "POST",
            data: data
        })
    },
    generateData: function (data) {
        return axios({
            url: baseUrl+"/generateData",
            method: "POST",
            data: data
        })
    },
    getReportsEpidemicOrder: function (params) {
        return axios({
            url: baseUrl+"/getReportsEpidemicOrder",
            method: "GET",
            params: params
        })
    },
    categorizedEpidemicOrder: function (ds) {
        return axios({
            url: baseUrl+"/categorizedEpidemicOrder",
            method: "GET",
            params: {ds: ds}
        })
    },
    getCategoryTemplateStatistics: function (ds) {
        return axios({
            url: baseUrl+"/getCategoryTemplateStatistics",
            method: "GET",
            params: {ds: ds}
        })
    },
    getReportsEpidemicStatistics: function (ds) {
        return axios({
            url: baseUrl+"/getReportsEpidemicStatistics",
            method: "GET",
            params: {ds: ds}
        })
    },
    changOrderKeyWord: function (data) {
        return axios({
            url: baseUrl+"/changOrderKeyWord",
            method: "POST",
            data: data
        })
    },
    generateExcelOrderDaily: function (ds) {
        //link.setAttribute('download', `${fileName}.xlsx`)
        return axios({
            url: baseUrl+"/generateExcelOrderDaily",
            method: "GET",
            params: {ds: ds},
            responseType: 'blob'
        }).then(res => {
          ExcelDownLoad(res)
            // //切割出文件名
            // const fileNameEncode = (res.headers['content-disposition'] || '').split('filename=')[1]
            // //解码
            // const fileName = decodeURIComponent(fileNameEncode)
            //   //decodeURIComponent(fileNameEncode)
            // // 设置type类型
            // const blob = new Blob([res.data], {
            //     type: 'application/vnd.ms-excel; charset=utf-8'
            // })
            // const link = document.createElement('a')
            // link.style.display = "none";
            // link.href = URL.createObjectURL(blob);
            // link.setAttribute('download', `${fileName}`)
            // document.body.appendChild(link);
            // link.click();
            // document.body.removeChild(link);
        })
    },
    changeCategoryContent: function (params){
        return axios({
            url: baseUrl+"/changeCategoryContent",
            method: "GET",
            params: params
        })
    },
    getReportsEpidemicHandleOrder: function (ds){
        return axios({
            url: baseUrl+"/getReportsEpidemicHandleOrderInfo",
            method: "GET",
            params: {ds: ds}
        })
    },
    editHandleOrder: function (data){
        return axios({
            url: baseUrl+"/editHandleOrder",
            method: "POST",
            data: data
        })
    },
    delHandleOrder: function (id){
        return axios({
            url: baseUrl+"/delHandleOrder",
            method: "GET",
            params: {id: id}
        })
    },
    getSummary: function (ds){
        return axios({
            url: baseUrl+"/getSummary",
            method: "GET",
            params: {ds: ds}
        })
    },
    submitSummary: function (data){
        return axios({
            url: baseUrl+"/submitSummary",
            method: "POST",
            data: data,
            responseType:'blob',
        }).then(res => {
          WordDownLoad(res)
        })
    },
    getStatisticsWeekData: function (ds){
        return axios({
            url: baseUrl+"/getStatisticsWeekData",
            method: "GET",
            params: {ds: ds}
        })
    },
    getWord: function(ds){
        return axios({
          url: baseUrl+"/generateWord",
          method: "GET",
          params: {ds: ds},
          responseType:'blob',
        })
    },
    generateWord: function (ds){
        return axios({
            url: baseUrl+"/generateWord",
            method: "GET",
            params: {ds: ds},
            responseType:'blob',
        }).then(res => {
          WordDownLoad(res)
            // console.log(res)
            // //切割出文件名
            // const fileNameEncode = (res.headers['content-disposition'] || '').split('filename=')[1]
            // //解码
            // const fileName = decodeURIComponent(fileNameEncode)
            // // 设置type类型
            // const blob = new Blob([res.data], {
            //     type: 'application/msword; charset=utf-8'
            // })
            // const link = document.createElement('a')
            // link.style.display = "none";
            // link.href = URL.createObjectURL(blob);
            // link.setAttribute('download', `${fileName}`)
            // document.body.appendChild(link);
            // link.click();
            // document.body.removeChild(link);
        })
    },
    editCategoryAddNum: function (params){
        return axios({
            url: baseUrl+"/editCategoryAddNum",
            method: "GET",
            params: params,
        })
    },
    getEpidemicStatisticsHome: function (params){
        return axios({
            url: baseUrl+"/getEpidemicStatisticsHome",
            method: "GET",
            params: params,
        })
    },
    getEpidemicCategoryStatisticsMerge: function(ds){
      return axios({
        url: baseUrl+"/getEpidemicCategoryStatisticsMerge",
        method: "GET",
        params: { ds:ds },
      })
    },
    mergeCategoryStatistics: function(data){
      return axios({
        url: baseUrl+"/mergeCategoryStatistics",
        method: "POST",
        data: data
      })
    },
  generateSummary: function(ds){
    return axios({
      url: baseUrl+"/generateSummary",
      method: "GET",
      params: { ds:ds },
    })
  },
  editCategoryPriority: function(params) {
    return axios({
      url: baseUrl+"/editCategoryPriority",
      method: "GET",
      params: params,
    })
  },
  getReportsEpidemicCategoryKey: function(params){
    return axios({
      url: baseUrl+"/getReportsEpidemicCategoryKey",
      method: "GET",
      params: params,
    })
  },
  editCategoryKeyPriority: function(params) {
    return axios({
      url: baseUrl+"/editCategoryKeyPriority",
      method: "GET",
      params: params,
    })
  },
  addCategoryKeywordByWExcel: function(data){
    return axios({
      url: baseUrl+"/addCategoryKeywordByWExcel",
      method: "POST",
      data: data,
      headers: {
        'Content-Type': 'multipart/form-data;'
      }
    })
  },
  delCategoryKeyBulk: function(data){
    return axios({
      url: baseUrl+"/delCategoryKeyBulk",
      method: "POST",
      data: data,
    })
  }
}